*This dofile analyzes the individual-level survey data from the IFPRI-EEPRI 2008–2009 dataset. It produces Tables 2, 3, 5, 6 (cols. 9-12), and the individual-level sum stats/ regressions in Tables S4, S8, S9, S10, and S11. It also outputs the coefficients used to create Figure 5 (in an R program).

*+++++++++++++ THE BEGINNING +++++++++++++++++++++++++++++++++++++++

clear
set more off

use ".\Data_Tables_2_3_5_6_S4_S8_S9_S10_S11_Figure_5_Coeffs.dta", replace


*_________________________________________________________________________________
******************************* REGRESSIONS **************************************
*---------------------------------------------------------------------------------

*** Set controls macro

#delimit;

local hh_controls
dm_male 
dm_literate 
dmedsecorhigher 
age 
age_sq
hh_cntrl_qty_HH_members 
hh_cntrl_land_own  
dmownhouse 
dmmorethan1room
dmlargelivestock
yourethshare;

#delimit cr


*** Locals for different sets of RHS variables
 
local M4b_lin 	 "D 	  	A1 A2 A3 	 A1_B  	A2_B  	A3_B 		   	 A1_S A2_S A3_S 		 A1_B_S    A2_B_S 	 A3_B_S    		        "
local M4c_lin	 "Dfal			 	 A4					 		A4_B 			 		A4_Sfal			 				 	    A4_B_Sfal   "
local M4d_lin 	 "D 	  	A2 A3 	 A2_B  	A3_B 		   	 A2_S A3_S 		 A2_B_S 	 A3_B_S    		        "

local M4b_squ 	 "																		  		 A1_Bsqu_S A2_Bsqu_S A3_Bsqu_S 	 	   	    "
local M4c_squ	 "																		  					  			        A4_Bsqu_Sfal"
local M4d_squ 	 "																		  		 A2_Bsqu_S A3_Bsqu_S 	 	   	    "

local M_b_squ 	 "					   	A1_Bsqu A2_Bsqu A3_Bsqu		   "
local M_c_squ	 "											   	A4_Bsqu"
local M_d_squ 	 "					   	A2_Bsqu A3_Bsqu		   "

local Dell_quad			"D 	  	A1 A2 A3 	latitude longitude lat2 long2 latlong"


**** Initialize all outreg files

local labb: var label hhd63_attend_ag_mtng
#delimit;
reg hhd63_attend_ag_mtng `M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  , nocon cluster(kebele); 
outreg2 using ".\Table_2.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
outreg2 using ".\Table_3.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;	
outreg2 using ".\Table_5.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
outreg2 using ".\Table_6_columns_9to12.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
outreg2 using ".\Table_S9_Individual_Level_Results.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace; 
outreg2 using ".\Table_S10_Individual_Level_Results.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4b_lin'    `M_b_squ' 	`M4b_squ' `Dell_quad'	  ) replace;
reg hhd63_attend_ag_mtng `M4c_lin'    `M_c_squ' 	`M4c_squ', nocon cluster(kebele); outreg2 using ".\Table_S8_Individual_Level_Results.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4c_lin'    `M_c_squ' 	`M4c_squ') replace;
reg hhd63_attend_ag_mtng `M4d_lin'    `M_d_squ' 	`M4d_squ', nocon cluster(kebele); outreg2 using ".\Table_S11_Individual_Level_Results.xls"		, bdec(4) e(all) se label(insert) ctitle(IGNORE, `labb') 
	  		  sortvar(`M4d_lin'    `M_d_squ' 	`M4d_squ') replace;
#delimit cr

tempfile four_pairs
   save `four_pairs'


*~~~~~~~~~ Full sample

use `four_pairs', clear
drop if A4==1

*TABLE 2 (MEETINGS FOR AGRICULTURAL INFORMATION)

#delimit;
foreach outcome of varlist hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng { ; 
local labb: var label `outcome'; foreach z in "" "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_2.xls", bdec(4) e(all) se label(insert) ctitle(Table 2, `outcome', `labb') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };
		  
*TABLE 3 (ACCESSING AND LEARNING FROM AGRICULTURAL EXTENSION/ TRAINING SERVICES);
		  
foreach outcome of varlist hh6_2ext_visit_qty hh2_2new_pract_qty { ; 
local labb: var label `outcome'; foreach z in "" "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_3.xls", bdec(4) e(all) se label(insert) ctitle(Table 3, `outcome', `labb') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

*TABLE 5 (SATISFACTION WITH GOVERNMENT-PROVIDED AGRICULTURAL SERVICES);

foreach outcome of varlist dmverysat_maj_agmeet dmverysat_maj_g_inputs { ; 
local labb: var label `outcome'; foreach z in "" "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_5.xls", bdec(4) e(all) se label(insert) ctitle(Table 5, `outcome', `labb') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

*TABLE 6, COLUMNS 9-12 (USE OF IMPROVED DRINKING WATER SOURCE);
		  
foreach outcome of varlist hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry { ; 
local labb: var label `outcome'; foreach z in "" "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_6_columns_9to12.xls", bdec(4) e(all) se label(insert) ctitle(Table 6 col 9-12, `outcome', `labb') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

*TABLE S10 (ROBUSTNESS TO DELL (2010) REGRESSION SPECIFICATION USING QUADRATIC IN LONGITUDE AND LATITUDE;
		  
foreach outcome of varlist hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng hh6_2ext_visit_qty hh2_2new_pract_qty dmverysat_maj_agmeet dmverysat_maj_g_inputs hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry { ; 
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `Dell_quad' `z', nocon cluster(kebele); outreg2 using ".\Table_S10_Individual_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S10, `outcome', `labb') 
		  sortvar(`Dell_quad') append; }; };		  
#delimit cr


*FIGURE 5 (PRODUCE DATASET FOR USE IN R -- THE PROGRAM USED TO CREATE THE INDIVIDUAL-LEVEL OUTCOMES PREDICTION FIGURE)

set more off
local indivlevoutcomes = "hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng hh6_2ext_visit_qty hh2_2new_pract_qty dmverysat_maj_agmeet dmverysat_maj_g_inputs hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry"
mat results = J(10,3,0)
local a=1
foreach var of varlist `indivlevoutcomes' {
	label variable `var' "`var'"
	eststo: quietly reg `var' `M4b_lin' `M_b_squ' `M4b_squ' `hh_controls', nocon cluster(kebele)
	mat results[`a',1] = _b[D]
	mat results[`a',2] = _se[D]
	mat results[`a',3] = `a'
	local ++a
	}
esttab using Figure_5_Coefficients.csv, b(4) se(3) starlevels(* 0.1 ** .05 *** .01) replace
mat2txt, matrix(results) saving(Figure_5_Coefficients) replace 
eststo clear


*TABLE S9 (INDIVIDUAL-LEVEL OUTCOMES FOR REGRESSIONS CHECKING ROBUSTNESS OF RESULTS TO USE OF NARROWER BANDWIDTHS)

*~~~~~~~~~ Within distance of 50km to the border

use `four_pairs', clear
drop if A4==1
drop if S>=50 | S<=-50

#delimit;
foreach outcome of varlist hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng hh6_2ext_visit_qty hh2_2new_pract_qty dmverysat_maj_agmeet dmverysat_maj_g_inputs hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry { ; 
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S9_Individual_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S9 within 50km, `outcome', `labb') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

#delimit cr

*~~~~~~~~~ Within distance of 25km to the border

use `four_pairs', clear
drop if A4==1
drop if S>=25 | S<=-25

#delimit;
foreach outcome of varlist hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng hh6_2ext_visit_qty hh2_2new_pract_qty dmverysat_maj_agmeet dmverysat_maj_g_inputs hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry { ; 
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4b_lin' `M_b_squ' `M4b_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S9_Individual_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S9 within 25km, `outcome', `labb') 
		  sortvar(`M4b_lin' `M_b_squ' `M4b_squ' ) append; }; };

#delimit cr


*TABLE S8 (INDIVIDUAL-LEVEL OUTCOMES FOR ROBUSTNESS CHECK SHOWING LACK OF SIGNIFICANT IMPACTS OF DECENTRALIZATION AT A REGIONAL BORDER WITH NO POLICY CHANGE)

use `four_pairs', clear
keep if A4==1

#delimit;
foreach outcome of varlist hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele hh6_2ext_visit_qty hh2_2new_pract_qty dmverysat_maj_agmeet dmverysat_maj_g_inputs hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry { ; 
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4c_lin' `M_c_squ' `M4c_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S8_Individual_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S8, `outcome', `labb') 
		  sortvar(`M4c_lin' `M_c_squ' `M4c_squ' ) append;  }; };
#delimit cr


*TABLE S11 (INDIVIDUAL-LEVEL OUTCOMES FOR ROBUSTNESS CHECK SHOWING RESULTS USING ONLY THE TWO BORDER SEGMENTS FOR WHICH BOTH WERE IN THE SAME PROVINCE DURING 1942--1995)

use `four_pairs', clear
keep if A2==1|A3==1

#delimit;
foreach outcome of varlist hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng hh6_2ext_visit_qty hh2_2new_pract_qty dmverysat_maj_agmeet dmverysat_maj_g_inputs hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry { ; 
local labb: var label `outcome'; foreach z in "`hh_controls'" {; 
qui reg `outcome' `M4d_lin' `M_d_squ' `M4d_squ' `z', nocon cluster(kebele); outreg2 using ".\Table_S11_Individual_Level_Results.xls", bdec(4) e(all) se label(insert) ctitle(Table S11, `outcome', `labb') 
		  sortvar(`M4d_lin' `M_d_squ' `M4d_squ' ) append;  }; };
#delimit cr


*TABLE S4 (INDIVIDUAL-LEVEL DESCRIPTIVE STATISTICS)

use `four_pairs', clear

drop if A4==1

estpost summarize hh6_2ext_visit_qty hh2_2new_pract_qty hhd63_attend_ag_mtng hhd3_com_mtng_imp_wereda hhd3_com_mtng_imp_kebele K_hhd63_attend_ag_mtng hh51_2sat_wat_qlty_wet hh52_2sat_wat_qlty_dry dmverysat_maj_agmeet dmverysat_maj_g_inputs D dm_male dm_literate dmedsecorhigher age hh_cntrl_qty_HH_members hh_cntrl_land_own dmownhouse dmmorethan1room dmlargelivestock yourethshare
estout using ".\Table_S4_Individual_Level_Sum_Stats.xls", replace cells("mean sd count") label


*+++++ THE END ++++++++++++++++++++++++++++++++++
